package com.me.adapter;

import java.util.ArrayList;
import java.util.List;

import android.content.Context;
import android.util.Log;
import android.widget.ArrayAdapter;
import android.widget.Filter;

public class KArrayAdaptor<T> extends ArrayAdapter<T> {
	private Filter filter = new KNoFilter();
	public List<T> suggested_items;

	@Override
	public Filter getFilter() {
		return filter;
	}

	public KArrayAdaptor(Context context, int textViewResourceId,
			List<T> suggested) {
		super(context, textViewResourceId, suggested);
		Log.v("Krzys", "Adapter created " + filter);
		suggested_items = suggested;
		
	}

	private class KNoFilter extends Filter {

		@Override
		protected FilterResults performFiltering(CharSequence arg0) {
			FilterResults result = new FilterResults();
			
				
				result.values = suggested_items;
				result.count = suggested_items.size();
				
			
			return result;
		}

		@Override
		protected void publishResults(CharSequence arg0, FilterResults arg1) {

			notifyDataSetChanged();
		}
	}
}
